// 引入函数组件的样式
import 'vant/es/toast/style';
import 'vant/es/dialog/style';
import 'vant/es/notify/style';
import 'vant/es/image-preview/style';
import '@/utils/fontSize';
import 'swiper/css';
import { createApp } from 'vue';
// 状态管理
import pinia from '@stores/index';
// 路由
import router from '@router/index';
import directives from '@directives/index';
import { useUserInfoStore } from '@stores/modules/user-info';
import VConsole from 'vconsole';
if (['development'].includes(import.meta.env.MODE)) {
	new VConsole();
}
import App from './App.vue';

const app = createApp(App);
directives(app);

app.use(pinia);
app.use(router);

app.mount('#app');

const userInfo = useUserInfoStore();

router.beforeEach((to: any, form, next) => {
	// 设置网页标题
	document.title = to?.meta?.title || '摄影大赛';
	if (to.query.appToken) {
		userInfo.setToken(to.query.appToken);
	}
	next();
});
